<?php
define('_file_','a_permission_touser');
if ( !isGod() )
	if ( !getRights($mod,'full') )
		if ( !News_getAccessFile(_file_) )
		{
			showMsg('Không có quyền truy cập vào trang này này !','ex','center');
			die();
		}
$un = getVar('un');		
		
$sql = "SELECT * FROM  mod_files WHERE modname='$mod'";
$rs = $link->execute($sql);

$sql = "SELECT * FROM um_user_access_mod_files WHERE username='$un' order by file_id";
$rs_p = $link->execute($sql);
$arr = $rs_p->GetArray();
$arrCnt = count($arr);
if ( $rs->EOF )
	showMsg('Chưa có dữ liệu !','info','center');
?>
<style type="text/css">
<!--
.style7 {font-family: Tahoma, verdana, arial; font-size: 11px; font-weight: bold; color: #FFFFFF; }
.style8 {color: #FFFFFF}
-->
</style>

<form action="admin.php?mod=<?= $mod ?>&act=a_permission_touser_process" method="post" name="frmPermission">
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
    <tr>
      <td height="30" align="center" bgcolor="#336699"><span class="style7">Stt</span></td>
      <td height="30" align="center" bgcolor="#336699"><span class="style7">Tên chức năng </span></td>
      <td height="30" align="center" bgcolor="#336699"><span class="style8"></span></td>
    </tr>
<?php
$stt = 0;
while ( !$rs->EOF )
{
	if ( $stt % 2 == 0 )	$clr = "#CCCCFF";
	else					$clr = "#F0F0F0";
	
	$str = '';
	for ( $i = 0; $i < $arrCnt; $i++ )
	{
		if ( $rs->fields('fid') == $arr[$i][1] )
			$str = "checked";
	}
?>	
    <tr>
      <td align="center" bgcolor="<?= $clr ?>"><?= $stt+1 ?></td>
      <td bgcolor="<?= $clr ?>">&nbsp;<?= $rs->fields('fdesc') ?></td>
      <td bgcolor="<?= $clr ?>" align="center"><input type="checkbox" name="chk_<?= $stt ?>" value="<?= $rs->fields('fid') ?>" <?= $str ?>></td>
    </tr>
<?php
	$stt++;
	$rs->movenext();
}
?>  
<tr><td colspan="3" align="right">
<input name="hidTotalRecord" type="hidden" value="<?= $stt ?>">
<input name="hun" type="hidden" value="<?= $un ?>">
<a href="javascript:CheckAll('frmPermission',false);">Bỏ chọn tất cả</a>&nbsp;|&nbsp;<a href="javascript:CheckAll('frmPermission',true);">Chọn tất cả</a>&nbsp;
</td></tr>
<tr><td height="40" bgcolor="#000066" colspan="3" align="right">
<input type="submit" name="cmdOK" value="Cấp quyền &raquo;">&nbsp;
</td></tr></table>